-
Notifications
You must be signed in to change notification settings - Fork 50
feat(lsp): add xgoGetProperties command for lsp #2837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @go-wyvern, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Language Server Protocol (LSP) integration by introducing a new command that allows clients to query for properties (fields and methods) of specific targets within the SPX project. This feature improves the editor's ability to provide richer contextual information, paving the way for more advanced code intelligence features like auto-completion and documentation lookups for game objects and sprites. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
…ndXGoGetProperties
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds a new SPX LSP workspace command (xgo.getProperties) to the GUI-side client/command typings so the editor can request target properties (e.g., for API reference/intellisense features).
Changes:
- Added
xgoGetPropertiescommand definition (arguments/result typing) inspxls/commands.ts. - Added a corresponding
SpxLSPClientwrapper method to execute the command viaworkspace/executeCommand. - Updated imports to include the new command.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
spx-gui/src/components/editor/code-editor/lsp/spxls/commands.ts |
Defines the new xgo.getProperties command and its argument/result types. |
spx-gui/src/components/editor/code-editor/lsp/index.ts |
Exposes a SpxLSPClient wrapper to execute the new command and updates imports accordingly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export namespace xgoGetProperties { | ||
| export const command = 'xgo.getProperties' | ||
| type XGoGetPropertiesParams = { | ||
| /** The target name, for example `Game` or a specific sprite name. */ | ||
| target: string | ||
| } | ||
| export type Arguments = [XGoGetPropertiesParams] | ||
| /** A property of a target type. */ | ||
| export type XGoProperty = { | ||
| /** The property name. */ | ||
| name: string | ||
| /** The property type as a string. */ | ||
| type: string | ||
| /** The kind of property. */ | ||
| kind: 'field' | 'method' | ||
| /** Optional documentation for the property. */ | ||
| doc?: string | ||
| } | ||
| export type Result = XGoProperty[] | ||
| } |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xgoGetProperties.Result is non-nullable (XGoProperty[]), but other xgo.* executeCommand results in this module are modeled as nullable (e.g., xgoRenameResources.Result, xgoGetInputSlots.Result). Since LSP workspace/executeCommand can legitimately return null, consider making this XGoProperty[] | null (and handling null at call sites) to match the established pattern and avoid potential runtime null handling bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a new LSP command xgoGetProperties to fetch properties for a given target. The implementation looks good, but I have a couple of suggestions to improve consistency and robustness.
First, the new method in SpxLSPClient is named workspaceExecuteCommandXGoGetProperty (singular), which is inconsistent with the command itself and other similar methods. I've suggested renaming it to the plural form workspaceExecuteCommandXGoGetProperties.
Second, the result type for the new command is defined as XGoProperty[], while other similar commands can return null. To prevent potential runtime errors and maintain consistency, I've recommended changing the result type to XGoProperty[] | null.
| /** Optional documentation for the property. */ | ||
| doc?: string | ||
| } | ||
| export type Result = XGoProperty[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with other commands like xgoGetInputSlots and to handle cases where the server might not find any properties or encounters an error, it's safer to allow null as a possible result. This prevents potential runtime errors if the server returns null and the client expects an array. Please also update the return type in SpxLSPClient.workspaceExecuteCommandXGoGetProperties accordingly.
| export type Result = XGoProperty[] | |
| export type Result = XGoProperty[] | null |
| ) | ||
| } | ||
|
|
||
| async workspaceExecuteCommandXGoGetProperties( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming Inconsistency: The method name workspaceExecuteCommandXGoGetProperty (singular) doesn't match the command namespace xgoGetProperties (plural) or the command string 'xgo.getProperties'.
This breaks the established pattern in the codebase:
xgoGetInputSlots→workspaceExecuteCommandXGoGetInputSlots✅xgoRenameResources→workspaceExecuteCommandXGoRenameResources✅xgoGetProperties→workspaceExecuteCommandXGoGetProperty❌
Recommendation: Rename to workspaceExecuteCommandXGoGetProperties (plural) for consistency.
| /** Optional documentation for the property. */ | ||
| doc?: string | ||
| } | ||
| export type Result = XGoProperty[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type Safety Issue: The Result type should include | null for consistency with other LSP commands.
Current: export type Result = XGoProperty[]
Compare with:
xgoGetInputSlots.Result = XGoInputSlot[] | null(line 31)xgoRenameResources.Result = lsp.WorkspaceEdit | null(line 10)
Recommendation: Change to export type Result = XGoProperty[] | null to ensure proper type safety if the LSP server returns null.
|
|
||
| async textDocumentDocumentLink( | ||
| ctx: RequestContext, | ||
| params: lsp.DocumentLinkParams |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing Convenience Method: Consider adding a higher-level getProperties wrapper method following the established pattern in this codebase.
Existing patterns:
getInputSlots(line 428) wrapsworkspaceExecuteCommandXGoGetInputSlotsgetCompletionItems(line 421) wrapstextDocumentCompletiongetResourceReferences(line 389) wrapstextDocumentDocumentLink
Suggested implementation:
async getProperties(ctx: RequestContext, target: string): Promise<xgoGetProperties.XGoProperty[]> {
const result = await this.workspaceExecuteCommandXGoGetProperties(ctx, { target })
if (result == null) return []
return result
}This would provide a cleaner API and improve maintainability.
| export const command = 'xgo.getProperties' | ||
| type XGoGetPropertiesParams = { | ||
| /** The target name, for example `Game` or a specific sprite name. */ | ||
| target: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Input Validation: The target parameter lacks validation. Consider adding constraints to ensure it conforms to expected patterns (identifier rules or "Game" literal).
Security consideration: While the LSP runs in a sandboxed Web Worker, adding validation provides defense in depth if the WASM language server has vulnerabilities in string handling.
Recommendation:
- Document the expected format and constraints explicitly
- Consider runtime validation for identifiers
- Add examples of valid vs invalid target values in the JSDoc
| /** The property name. */ | ||
| name: string | ||
| /** The property type as a string. */ | ||
| type: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation Enhancement: Consider adding more detailed JSDoc for the type field:
- What format does the type string use? (Go type syntax? Simplified names?)
- Examples of common type values (e.g., "int", "string", "func()", etc.)
This would help developers understand what to expect from the API response.
Code Review SummaryReviewed this PR adding the Critical:
Recommended:
Overall solid implementation, just needs consistency fixes. |
No description provided.